<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class conectaPDO {
    
    /**
     * Conexao com o banco de dados
     * @var PDO
     */
    protected static $pdo;

    /**
     * Metodo statico que conecta com o banco de dados
     * @return PDO conexao com o banco de dados 
     */
    public static function get_pdo(){
        if (!isset (self::$pdo)){
            try {
                self::$pdo = new PDO($GLOBALS["bd_path"], $GLOBALS["bd_user"], $GLOBALS["bd_password"], array(
                    PDO::ATTR_PERSISTENT => FALSE,
                    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
                ));
//                self::$pdo->exec("SET CHARACTER SET latin1");
                self::$pdo->exec("SET CHARACTER SET UTF8");
            } catch (PDOException $e) {
                print "Error!: " . $e->getMessage() . "<br/>";
                die();
            }
        }
        return self::$pdo;
    }
    
}
?>
